function getQueryString(name) {
	var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
	var r = window.location.search.substr(1).match(reg);
	if (r != null)
		return unescape(r[2]);
	return null;
}
function replaceTextarea(str){
    var reg=new RegExp("\n","g");
    str = str.replace(reg,"</p><p>");
    return "<p>"+str+"</p>";
}
$("#clubBtn").click(function() {
	var title = $.trim($('#title').val());
	var content = $.trim($('#content').val());
	content = replaceTextarea(content);
	
	var clubId = getQueryString('clubId');
	if (title == "" || content == "") {
		$('#error').text('信息不能为空').show();
		return;
	} else {
		$.ajax({
			url : localhost + "memorabilia/insert",
			dataType : "jsonp",
			data : {
				title : title,
				content : content,
				clubId : clubId
			},
			jsonp : "jsonpCallback",
			success : function(data) {
				if (data <= 0) {
					$("#error").html("*添加失败*");
				} else {
					$("#error").html("*添加成功*");
					window.location.href = "index.shtml";
				}
			}
		});
	}
});